<template>
  <div class="compitem">
    <div class="compname">{{title}}</div>
     <el-checkbox v-model="checked" style="width:20px;"></el-checkbox>
    <div class="compname" style="text-align: center;">最小单元</div>
     
    <el-input style="width:90px;" v-model="value"></el-input>
  </div>
</template>
<script>
export default {
  props:{
   title:{
     type:String
   },
   name:{
     type:String
   },
   val:{
     type:String
   },

  },
  data() {
    return {
      value:'',
      checked:false
    }
  },
  created() {
    // this.value=this.val
    if(this.val){
      var data=JSON.parse(this.val)
      if(data.type==1){
        this.checked=true
      }else{
        this.checked=false
      }
      this.value=data.val
    }
  },
  watch: {
    value:function(params) {
      // console.log(this)
      this.$emit('func',{name:this.name,data:{type:this.checked?1:2,val:this.value}})
    },
    checked:function(){
      this.$emit('func',{name:this.name,data:{type:this.checked?1:2,val:this.value}})
    }
  },
}
</script>
<style lang="scss" scoped>
.compitem{
  .compname{
    font-size: 14px;
    width: 90px;
    // padding: 0 15px;
    // padding-right:15px;

  }
  width: 100%;
  display: flex;
   align-items: center;
}
</style>